<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Admin\Controller;
use Think\Controller;
class ConsumeController extends IndexController {
	
	//列表动作-----------------------------------------------------------------------------------------------
	public function indexAction(){
		
		$model=new \Admin\Model\ConsumeModel();

		$sqlwhere=array(' paytype<%d ',array('paytype'=>3));
		if(!empty($_GET['amount'])){
			$_GET['amount']=intval($_GET['amount'])*100;
		}
		foreach($model->IndexGetData(
				//排序
				array(
					array('order'=>'id','name'=>'ID'),
					array('order'=>'serial','name'=>'流水号'),
					array('order'=>'dataid','name'=>'任务ID'),
					array('order'=>'subject','name'=>'标题'),
					array('order'=>'payin_uid','name'=>'收入用户UID'),
					array('order'=>'payin_username','name'=>'收入用户名'),
					array('order'=>'payin_money','name'=>'收入后金额'),
					array('order'=>'payout_uid','name'=>'付款用户UID'),
					array('order'=>'payout_username','name'=>'付款用户名'),
					array('order'=>'payout_money','name'=>'支付后金额'),
					array('order'=>'amount','name'=>'交易金额'),
					array('order'=>'fee','name'=>'手续费'),
					array('order'=>'refundmoney','name'=>'退款金额'),
					array('order'=>'unionuid','name'=>'推广员UID'),
					array('order'=>'process','name'=>'交易状态'),
					array('order'=>'dateline','name'=>'发布时间'),
					array('order'=>'endtime','name'=>'交易完成时间')
				),
				//查询
				array(	
					'subject'=>array('subject','search'),
					'id'=>array('id','int'),
					'amount'=>array('amount','int'),
					'payin_uid'=>array('payin_uid','int'),
					'payout_uid'=>array('payout_uid','int'),
					'payin_username'=>array('payin_username','string'),
					'payout_username'=>array('payout_username','string'),
					'dateline1'=>array('dateline','time'),
					'dateline2'=>array('dateline','time'),
				)
				,
				'id DESC'
				,
				20				
				,
				$sqlwhere
				
			) as $key=>$value){
			$this->assign($key,$value);
		}

		$this->display();
	}
	
	//关闭动作-----------------------------------------------------------------------------------------------
	public function closeAction(){
		$model=new \Consume\Model\ConsumeModel();
		$id=intval($_GET['id']);
		if($id){
			if($model->CloseConsume($id)){
				$result['message']=$id.'号订单关闭成功!';
			}else{
				$result['message']=$id.'号订单当前状态无法关闭!';
			}
		}
		
		$this->error($result['message'],U(MODULE_NAME.'/'.CONTROLLER_NAME.'/index'),3);
	}
	
	//删除动作-----------------------------------------------------------------------------------------------
	public function deleteAction(){
		$model=new \Admin\Model\ConsumeModel();
		$result=$model->DeleteData();
		$this->error($result['message'],U(MODULE_NAME.'/'.CONTROLLER_NAME.'/index'),3);
	}
	
}